import request from "./request.js"

const apiValue = "1aea00069d6412d77e6ed38e2af15cf7"

// 通过ip地址查询所在城市
export const getCityNameForIp = (ipAddress) => {
  return request({
    url: "/ip",
    method: "GET",
    params: {
      ip: ipAddress,
      key: apiValue,
    },
  })
}

//  通过城市名查询adcode
export const getAdcodeForCityName = (cityAddress,cityName) => {
  return request({
    url: "/geocode/geo",
    method: "GET",
    params: {
      address: cityAddress,
      key: apiValue,
    },
    if (cityName) {
      params.city = cityName;
    }
  })
}

//  通过adcode查询城市天气

export const getCityWeatherForAdcode = (adcode, extensions) => {
  return request({
    url: "/weather/weatherInfo",
    method: "GET",
    params: {
      city: adcode,
      key: apiValue,
      extensions: extensions,
    },
  })
}
